package com.ljn.service.imp;

import com.ljn.core.dto.Project;
import com.ljn.core.dto.common.Page;
import com.ljn.core.dto.common.command.projectcommand.QueryProCommand;
import com.ljn.mapper.AdminMapper;
import com.ljn.service.AdminService;

import javax.inject.Inject;
import javax.inject.Named;
import java.util.List;

/**
 * Created by liujunnan on 2017/11/16.
 */
@Named
public class AdminServiceImpl implements AdminService {

    @Inject
    AdminMapper adminMapper;

    @Override
    public Page<Project> show(QueryProCommand queryProCommand) {
        boolean status = false;
        int totalRecord = adminMapper.getCountByCondition(status);
        int pageCode = queryProCommand.getPage().getPageCode();
        Page<Project> pro = new Page<Project>(pageCode, totalRecord);
        List<Project> datas = adminMapper.pageByCondition((pageCode - 1) * pro.getPageSize(), pro.getPageSize(), status);
        pro.setDatas(datas);
        return pro;
    }

    @Override
    public boolean changeStatus(QueryProCommand queryProCommand) {
        boolean status = true;
        return this.adminMapper.updateStauts(queryProCommand,status);
    }
}
